<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="../static/js/vue.js"></script>
</head>

<body>
<h3>示例：todo</h3>
<p>
    使用is="todo-item"实现，而不是使用自定义标签&lt;todo-item>&lt;/todo-item>
</p>
<div id="todo-list-example">
    <ul>
        <li
                is="todo-item"
                v-for="(todo, index) in todos"
                v-bind:k="todo.id"
                v-bind:t="todo.title"
                v-bind:item="todo"currentTabComponent
                v-on:remove="todos.splice(index, 1)"
        ></li>
    </ul>
</div>

<script>
    Vue.component('todo-item', {
        template: '<li>\
      {{ t }}-{{ k }}-{{ item }}\
      <button v-on:click="$emit(\'remove\')">Remove</button>\
    </li>',
        props: ['t','k','item']
    })

    new Vue({
        el: '#todo-list-example',
        data: {
            newTodoText: '',
            todos: [
                {
                    id: 1,
                    title: 'Do the dishes',
                },
                {
                    id: 2,
                    title: 'Take out the trash',
                },
                {
                    id: 3,
                    title: 'Mow the lawn'
                }
            ],
            nextTodoId: 4
        },
        methods: {
            addNewTodo: function () {
                this.todos.push({
                    id: this.nextTodoId++,
                    title: this.newTodoText
                })
                this.newTodoText = ''
            }
        }
    })
</script>
</body>
</html>
